PATH![]() |
![]() ![]() |
Although each created task may execute separately, it may need to share information or otherwise communicate with other tasks. For example, Task 1 may write information to memory that will be read by Task 2. In order for such operations to occur successfully, some synchronization method must exist to make sure that Task 2 does not attempt to read the memory until Task 1 has completed writing the data and until Task 2 knows that valid data actually exists in memory. The latter scenario can be an issue when using multiple processors, because the PowerPC architecture allows for writes to memory to be deferred. In addition, if multiple tasks are waiting for another task to complete, synchronization is necessary to ensure that only one task can respond at a time.
Multitasking environments offer several ways for tasks to coordinate and synchronize with each other. The sections that follow describe three notification mechanisms (or signaling mechanisms) that allow tasks to pass information between them, and one task sharing method.
Note that the time required to perform the work in a given request should be much more than the amount of time it takes to communicate the request and its results. Otherwise, delegating work to tasks may actually reduce overall performance. Typically the work performed should be greater than the intertask signalling time (20-50 microseconds).
Note that you should avoid creating your own synchronization or sharing methods, because they may work on some Mac OS implementations but not on others.